import Layout from "../components/common/Layout"

import Login from "../components/client/Login"
import Register from "../components/client/Register"
import Home from "../components/client/Home"
import Answer from "@/components/client/Answer"
import ChoicePaper from "@/components/client/ChoicePaper"
import ExamHistory from "@/components/client/ExamHistory"
import WrongBook from "@/components/client/WrongBook"
import Logout from "@/components/client/Logout"

import VueRouter from "vue-router"

const router = new VueRouter({
    mode:"history",
    routes:[
        {
            path: "/",
            redirect: "login",
            hidden: true,
        },
        {
            path: "/login",
            name: "Login",
            component: Login,
            hidden: true,
            meta: {
                title:"用户登录"
            }
        },
        {
            path: "/register",
            name: "register",
            component: Register,
            hidden: true,
            meta: {
                title:"用户注册"
            }
        },
        {
            path:"/home",
            name:"账户信息",
            component:Layout,
            redirect:"/dashboard",
            meta: {
                title: '个人空间'
            },
            children:[
                {
                    path:"/dashboard",
                    name:"dashboard",
                    component:Home,
                    meta: {
                        title:"答题大数据"
                    }
                },
                {
                    path:"/answer/:paperId",
                    name:"answer",
                    component:Answer,
                    meta: {
                        title:"答题"
                    }
                },
                {
                    path:"/choice-paper",
                    name:"choicePaper",
                    component:ChoicePaper,
                    meta: {
                        title:"选择试卷"
                    }
                },
                {
                    path:"/exam-history",
                    name:"choicePaper",
                    component:ExamHistory,
                    meta: {
                        title:"考试历史"
                    }
                },
                {
                    path: "/wrong-book",
                    name: "WrongBook",
                    component:WrongBook,
                    meta: {
                        title:"错题本"
                    }
                },
                {
                    path:"/logout",
                    name:"logout",
                    component:Logout,
                    meta: {
                        title:"退出"
                    }
                }
            ]
        }
        // {
        //     path: "/admin/login",
        //     name: "AdminLogin",
        //     component: AdminLogin,
        //     meta: {
        //         title:"管理员登陆"
        //     }
        // },
        // {
        //     path: "/admin",
        //     name: "admin",
        //     component: AdminLayout,
        //     children: [
        //         {
        //             path: "/admin/home",
        //             name: "Home",
        //             component: AdminHome,
        //             meta: {
        //                 title:"管理员页面"
        //             }
        //         },
        //         {
        //             path: "/admin/make-paper",
        //             name: "MakePaper",
        //             component: MakePaper,
        //             meta: {
        //                 title:"创建试卷"
        //             }
        //         },
        //         {
        //             path: "/admin/all-paper",
        //             name: "AllPaper",
        //             component: AllPaper,
        //             meta: {
        //                 title: "全部试卷"
        //             }
        //         }
        //     ]
        // }
    ]
})

router.beforeEach((to,from,next)=>{
    document.title = to.meta.title
    next()
})

export default router